package com.dldata.devtools30.utils.filelistener;

import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

public class FileListenerCommon extends FileAlterationListenerAdaptor{


    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void onDirectoryChange(File directory) {
        logger.info("文件目录变更了:"+directory.getAbsolutePath());
    }

    @Override
    public void onDirectoryCreate(File directory) {
        logger.info("文件目录创建了:" + directory.getAbsolutePath());
    }

    @Override
    public void onDirectoryDelete(File directory) {
        logger.info("文件目录删除了:" + directory.getAbsolutePath());
    }

    @Override
    public void onFileChange(File file) {
        logger.info("文件变更了:" + file.getAbsolutePath());
    }

    @Override
    public void onFileCreate(File file) {
        logger.info("文件创建了:" + file.getAbsolutePath());
    }

    @Override
    public void onFileDelete(File file) {
        logger.info("文件删除了:" + file.getAbsolutePath());
    }

    @Override
    public void onStart(FileAlterationObserver observer) {
        logger.info("开始检查:" + observer.getDirectory());
    }

    @Override
    public void onStop(FileAlterationObserver observer) {
        logger.info("结束检查:" + observer.getDirectory());
    }

}


